#include "cardatawin.h"
#include "ui_cardatawin.h"

CarDataWin::CarDataWin(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CarDataWin)
{
    ui->setupUi(this);
    ui->lcd_speed_L->display(0);
    ui->lcd_speed_R->display(0);
    ui->label_batter->setText("-");
    ui->label_temp->setText("-");
    ui->label_accX->setText("-");
    ui->label_accY->setText("-");
    ui->label_accZ->setText("-");
    ui->label_gyroX->setText("-");
    ui->label_gyroY->setText("-");
    ui->label_gyroZ->setText("-");
}

CarDataWin::~CarDataWin()
{
    delete ui;
}

void CarDataWin::setData(CarData data)
{
    ui->lcd_speed_L->display(data.speed_L);
    ui->lcd_speed_R->display(data.speed_R);
    ui->label_batter->setText(QString::number(data.battery));
    ui->label_temp->setText(QString::number(data.temp));
    ui->label_accX->setText(QString::number(data.acc_X));
    ui->label_accY->setText(QString::number(data.acc_Y));
    ui->label_accZ->setText(QString::number(data.acc_Z));
    ui->label_gyroX->setText(QString::number(data.gyro_X));
    ui->label_gyroY->setText(QString::number(data.gyro_Y));
    ui->label_gyroZ->setText(QString::number(data.gyro_Z));

    ui->label_pwm_1->setText(QString::number(data.pwmMotorL));
    ui->label_pwm_2->setText(QString::number(data.pwmMotorR));
    ui->label_pwm_3->setText(QString::number(data.angleServoV));
    ui->label_pwm_4->setText(QString::number(data.angleServoH));
}
